/************************************************************ File: common.cc Description: A program that inputs a matrix from a file and computes the Cholesky decomposition using several processes. This file contains communication functions. Author: Dana Vrajitoru Organization: IUSB Date: August 16, 2002 **************************************************************/ #include #include "common.h" // Receives an array of floats of the given size from the proc_id // process. void Receive_float_array(int proc_id, float *array, int size) { MPI_Status status; MPI_Recv(array, size, MPI_FLOAT, proc_id, 0, MPI_COMM_WORLD, &status); } // Sends an array of floats of the given size to the proc_id process. void Send_float_array(int proc_id, float *array, int size) { MPI_Send(array, size, MPI_FLOAT, proc_id, 0, MPI_COMM_WORLD); } // Receives an array of integers of the given size from the proc_id // process. void Receive_int_array(int proc_id, int *array, int size) { MPI_Status status; MPI_Recv(array, size, MPI_INT, proc_id, 0, MPI_COMM_WORLD, &status); } // Sends an array of integers of the given size to the proc_id // process. void Send_int_array(int proc_id, int *array, int size) { MPI_Send(array, size, MPI_INT, proc_id, 0, MPI_COMM_WORLD); } // The source process broadcasts an array of integers of the given // size. void Cast_int_array(int source, int *array, int size) { MPI_Bcast(array, size, MPI_INT, source, MPI_COMM_WORLD); } // Computes the minimum of two integers int min(int arg1, int arg2) { if (arg1 <= arg2) return arg1; else return arg2; }